﻿@page "/admin/settings"
@inherits SettingsBase

<MatH4>@L["MainSettings"]</MatH4>

@if (settings == null)
{
    <LoadingBackground ShowLogoBox="true">
        <label>@L["Loading"]</label>
    </LoadingBackground>
}
else
{
    <EditForm Model="@settings">
        <FluentValidationValidator />
        <ValidationSummary />
        <fieldset>
            <div class="form-group">
                <MatSelectItem @bind-Value="@settings[SettingKey.MainConfiguration_Runtime].Value" Items="@BlazorRuntimes" Label="@L["Blazor Runtime"]"></MatSelectItem>
            </div>
        </fieldset>
    </EditForm>

    <MatButton OnClick="@(()=>apiClient.CancelChanges())">@L["Cancel"]</MatButton>
    <MatButton OnClick="@SaveChanges">@L["Save"]</MatButton>
}

@code {

    private string[] BlazorRuntimes { get; set; } = ((BlazorRuntime[])Enum.GetValues(typeof(BlazorRuntime))).Select(i => i.ToString()).ToArray();

    protected override async Task OnInitializedAsync()
    {
        await LoadSettings("MainConfiguration_");
    }
}
